<%@page import="java.nio.file.attribute.UserDefinedFileAttributeView"%>
<html>
	<head>
		<meta name="layout" content="main"/>
		<link rel="stylesheet" href="${resource(dir: 'css', file: 'bootstrap.css')}" type="text/css"/> 
		<link rel="stylesheet" href="${resource(dir: 'css', file: 'image.css')}" type="text/css"/> 
		<title>uTalk - Profile</title>
	</head>
	<body>
	
	<ul class="nav nav-pills">
 	 	<li><a href="${createLink(controller:'user', action:'home')}">Home</a></li>
  		<li class="active"><a href="${createLink(controller:'user', action:'profile')}">Profile</a></li>
  		<li><a href="${createLink(controller:'user', action:'message')}">Messages</a></li>
	</ul>
		
	<%--<div>Nombre de Follower : ${mapInfo?.numberFollower}</div>
	<div>Nombre d'abonnements : ${mapInfo?.numberFollow}</div>
	<div>Nombre de talks : ${mapInfo?.numberTalk}</div>--%>
	<div class="panel panel-default">
		<g:if test="${mapInfo?.userDetails?.path == null}">
			<div class="media">
	    		<img class="media-object thumb" src="${resource(dir: 'images', file: 'inconu.gif')}">
			</div>
		</g:if>
		<g:else>
			<div class="media">	
				<g:if test="${mapInfo?.userDetails?.url == true}">
	    			<img class="media-objec thumb" src="${mapInfo?.userDetails?.path}">
	    		</g:if>
	    		<g:else>
	    			 <img class="media-objec thumb" src="${resource(dir: 'images', file: "${mapInfo?.userDetails?.path}")}">
	    		</g:else>
			</div>
		</g:else>
  		<div class="panel-body">
    		@${mapInfo?.userDetails?.pseudo}
 		</div>
	</div>
	
	<!-- Si c'est la page profil de l'utilisateur connecté -->
	<g:if test="${flash.details == "NO"}">
	<g:uploadForm controller="user" action="uploadFile" role="form">
		<input type="file" name="avatar"/>
		<button type="submit">Send</button>
	</g:uploadForm>
	</g:if>
	
	<div>${flash?.fail_file}</div>
	
	<g:form action="subscribe" controller="user" role="form" params="${[userSubscribe : mapInfo?.userDetails?.pseudo]}">
	<g:if test="${flash.details == "NO"}">	<!-- Si c'est la page profil de l'utilisateur connecté -->
	
	</g:if>
	<g:else> <!--  Sinon on affiche un bouton s'abonner --><%--
		<g:hiddenField name="userToSubscribe" value="${mapInfo?.userDetails?.pseudo}"/>
		--%><div class="btn-group">
	  		<button type="submit" class="btn btn-default">Subscribe</button>
		</div>
	</g:else>
	</g:form>

	<br/><br/>
	<ol class="breadcrumb">
  	<li class="active">Nombre de Follower : ${mapInfo?.numberFollower}</li>
  	<li class="active">Nombre d'abonnements : ${mapInfo?.numberFollow}</li>
  	<li class="active">Nombre de talks : ${mapInfo?.numberTalk}</li>
	</ol>
	

	<ul class="list-group">
	<g:each var="tweets" in ="${mapInfo?.listTweets}">
    	<li class="list-group-item">${tweets.userSender.pseudo} = ${tweets.message} à ${tweets.dateWrite}</li>
	</g:each>
	</ul>
		
	</body>
</html>